Vue Js Remove Hash(#) from URL in Vue-Router: Vue.js provides a way to remove the hash(#) from the URL by using the router’s history mode. Simply use createWebHistory() in the Vue Router Configuration to enable history. With this mode, the HTML5 history API provides developers with the ability to change and update the browser’s URL without reloading the page, thus making it easier for users to access pages via direct URLs and enabling a better user experience.
Remove Hash(#) from URL in Vue Router 4.0
By using createWebHistory() instead of createWebHashHistory(), we are able to remove the hash(#) internally added in the URL. createWebHistory() is an API available in Vue Router that allows users to manage and maintain their browser history without the need to use hash (#) in URLs
Vue Js remove the hash(#) internally added in the URL
<script>
import { createRouter, createWebHistory } from 'vue-router'
const router = createRouter({
history: createWebHistory(),
routes: [ // routes here ]
})
</script>
Remove Hash(#) from URL in Vue Router 3.0
In Vue Router 3, to remove hash from the URL, we have to set the mode of the router to history mode .
Remove hash from url vue-router |Examplw
const router = new VueRouter({
mode: 'history',
routes: [...]
})